package com.dstz.demo.rest.controller;

import com.dstz.base.rest.BaseController;
import com.dstz.demo.core.manager.AclStandardPriceManager;
import com.dstz.demo.core.model.AclStandardPrice;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/sys/AclStandardPrice")
public class AclStandardPriceController extends BaseController<AclStandardPrice> {
    @Resource
    AclStandardPriceManager aclStandardPriceManager;
    @Override
    protected String getModelDesc() {
        return null;
    }
    @GetMapping("/findlist/{id}")
    public List<AclStandardPrice> findlist(@PathVariable("id") String id){
        String materialcoding=id.substring(0,id.lastIndexOf("."));
        String[] res=materialcoding.split("\\.");
        List<AclStandardPrice> list=new ArrayList<>();
        List<AclStandardPrice> list1=aclStandardPriceManager.findlist(materialcoding);
        for (int i=0;i<list1.size();i++){
            String materialcoding1 = list1.get(i).getMaterialcoding();
            String[] num=materialcoding1.split("\\.");
            if(res.length==num.length){
                list.add(list1.get(i));
            }
        }
        return  list;
    }
}
